//package com.mutong.project.common.intercepter;
//
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
///**
// * @author 霍咨文 on 2019/5/8.
// * @version 1.0
// */
//
//@Component
//public class LoginInterceptor implements HandlerInterceptor {
//
//
//    /**
//     * 获取session并判断 若username 不存在 则重定向到login.html 存在则进入controller中对应的方法
//     * @param request
//     * @param response
//     * @param o
//     * @return
//     * @throws Exception
//     */
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
//
//        HttpSession session = request.getSession();
//        //用户已登录
//        if (session.getAttribute("username") != null) {
//            return true;
//        } else {//用户未登录，直接跳转登录页面
//            response.sendRedirect("/web/login.html");
//            return false;
//        }
//
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
//
//    }
//
//    @Override
//    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
//
//    }
//
//}
